﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'ReporteVehiculos')
	BEGIN
		DROP  Procedure  ReporteVehiculos
	END

GO

CREATE Procedure ReporteVehiculos

	(
		@numero nvarchar(10)
	)


AS
begin
SELECT     dbo.Bien.Nombre, 
           dbo.Bien.StockActual,
           dbo.Vehiculo.Modelo,
           dbo.Vehiculo.NroPlaca,
           case
           when dbo.Vehiculo.TipoVehiculo=0 then 'Automovil'
           when dbo.Vehiculo.TipoVehiculo=1 then 'MotoCicleta'
           when dbo.Vehiculo.TipoVehiculo=2 then 'Camioneta'
           when dbo.Vehiculo.TipoVehiculo=3 then 'CamionCarga'
           end as 'Tipo',
           dbo.Vehiculo.Marca
FROM       dbo.Bien INNER JOIN
           dbo.Vehiculo ON dbo.Bien.IdBien = dbo.Vehiculo.IdBien
           where dbo.Vehiculo.NroPlaca like @numero +'%'
          
end

GO


GRANT EXEC ON ReporteVehiculos TO PUBLIC

GO


